#ifndef HEAD_H
#define HEAD_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <shadow.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <arpa/inet.h>
#include <stdbool.h>
#include <crypt.h>
#include <termios.h>
#include "log.h"
#include "transfile_client.h"
#include <pthread.h>
#include <signal.h>
typedef enum {
    LOGIN = 101,
    REGISTER = 102,
    ACCOUNTDELETE = 103,
    CD = 201,
    LS = 202,
    PWD = 203,
    MKDIR = 204,
    RMDIR = 205,
    RM = 206,
    PUTS = 301,
    GETS = 302,
    NOCOMMAND = 401,
    TREE = 501,
} commandType_t;

typedef struct {
    commandType_t type;
    int length;
    char value[4096];
} tlvPacket_t;


// 初始化TCP连接
int tcpInit(const char *ip, const char *port);

// 登陆验证
int loginCheck(char *username, const int sockfd, char *passwd);

// 获取密码并关闭回显
void setEcho(bool enable);
char *getPassword(const char *prompt);

// 命令识别并处理
int dealCommand(const int sockfd, const char *username, 
                const char *passwd, const char *token,
                const char *ip, const char *port);
#endif
